home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / rvga01.zip / T_EXP-03.C < prev    next >
C/C++ Source or Header  |  1994-08-10  |  4KB  |  151 lines

  1. /**********************************************
  2.  
  3.     Example #03 for the Reglage VGA-Library
  4.  
  5.         TEXT MODE
  6.         Character Height Experimenting
  7.  
  8.     V1.1 - Reglage (C) 1994
  9.  
  10. **********************************************/
  11.  
  12. #include "Keyb.h"
  13. #include "VGA.h"
  14. #include "VGA_T.h"
  15. #include    "VGA_BIOS.h"
  16.  
  17. #include "CooLogo.c"                    //    Not forgetting the C00lEsT logotype...
  18.  
  19.  
  20. /**********************************************
  21.  
  22.     main() ... Just a little test!
  23.  
  24. **********************************************/
  25.  
  26. int main(void)
  27. {
  28.     UWORD i,j,x,y;
  29.     UBYTE ocurx,ocury;
  30.     int dir=1,fade,vmode;
  31.  
  32.     UWORD oldscreen[0x4000];
  33.  
  34.     struct Palette OldPalette[16];
  35.     struct Palette NewPalette[16];
  36.  
  37.     vmode=V_GetMode();                        // Get Current VideoMode
  38.     VB_GetCursorPos(&ocurx,&ocury);        //    Get Original Cursor Positions
  39.  
  40.     for(j=0;j<16;j++)
  41.         T_GetPal(j,&OldPalette[j]);//    Store Old Palette
  42.  
  43.     for(j=0;j<0x4000;j++)            //    Store Old DOS-Screen
  44.         oldscreen[j]=T_screen[j];
  45.  
  46.     VB_SetCursor(0);                    //    Set Cursor Invisible [BIOS]
  47.  
  48.     for(fade=0x40;fade>0;fade--)    //    Fade Out DOS-Screen
  49.     {
  50.         for(j=0;j<16;j++)
  51.         {
  52.             NewPalette[j].R=(OldPalette[j].R*fade)>>6;
  53.             NewPalette[j].G=(OldPalette[j].G*fade)>>6;
  54.             NewPalette[j].B=(OldPalette[j].B*fade)>>6;
  55.             T_SetPal(j,&NewPalette[j]);
  56.         }
  57.         V_WaitVB();                        //    Wait for Vertical Blanking
  58.     }
  59.  
  60.     V_SetMode(0x83);                        //    Set TextMode 80x25, No Blanking
  61.     for(j=0;j<16;j++)                    //    Set Palette to BLACK
  62.     {
  63.         NewPalette[j].R=0;
  64.         NewPalette[j].G=0;
  65.         NewPalette[j].B=0;
  66.         T_SetPal(j,&NewPalette[j]);
  67.     }
  68.  
  69.     T_SetCursor(0);                    //    Set Cursor Invisible
  70.     T_ClearScreen(0);                    //    Clear ALL Screen Memory
  71.  
  72.     for(x=0;x<COOLOGO_WIDTH;x++)    //    Move the COOLOGO to the Screen
  73.         for(y=0;y<(COOLOGO_DEPTH);y++)
  74.             T_screen[y*T_width+x+15]=COOLOGO[(x+y*COOLOGO_WIDTH)*2]+(COOLOGO[(x+y*COOLOGO_WIDTH)*2+1]<<8);
  75.  
  76.     K_EatKbHit();                        //    Eat Keypresses
  77.  
  78.     while(K_KbHit())                    //    Continue while no keypresses
  79.     {
  80.         if(fade<0x40)                    //    Fade In!
  81.         {
  82.             for(j=0;j<16;j++)
  83.             {
  84.                 NewPalette[j].R=(OldPalette[j].R*fade)>>6;
  85.                 NewPalette[j].G=(OldPalette[j].G*fade)>>6;
  86.                 NewPalette[j].B=(OldPalette[j].B*fade)>>6;
  87.                 T_SetPal(j,&NewPalette[j]);
  88.             }
  89.             fade++;
  90.         }
  91.  
  92.         i+=dir;
  93.         if(i>0x1e)                        //    Height 0x1f is MAX
  94.             dir=-1;
  95.         if(i<0x01)                        //    ...and ofcourse, 0 is MIN
  96.             dir=1;
  97.  
  98.         T_CharHeight(i);                //    Set Character Height
  99.  
  100.         V_WaitVB();                        //    Wait for Vertical Blanking
  101.     }
  102.  
  103.     while(fade>=0)                        //    Fade Out!
  104.     {
  105.         for(j=0;j<16;j++)
  106.         {
  107.             NewPalette[j].R=(OldPalette[j].R*fade)>>6;
  108.             NewPalette[j].G=(OldPalette[j].G*fade)>>6;
  109.             NewPalette[j].B=(OldPalette[j].B*fade)>>6;
  110.             T_SetPal(j,&NewPalette[j]);
  111.         }
  112.         fade--;
  113.         V_WaitVB();                        //    Wait for Vertical Blanking
  114.     }
  115.  
  116.     V_SetMode(vmode|0x80);            //    Set Original VideoMode, No Blanking
  117.     VB_SetCursor(0);                    //    Set Cursor Invisible [BIOS]
  118.  
  119.     for(j=0;j<16;j++)                    //    Set Palette to BLACK
  120.     {
  121.         NewPalette[j].R=0;
  122.         NewPalette[j].G=0;
  123.         NewPalette[j].B=0;
  124.         T_SetPal(j,&NewPalette[j]);
  125.     }
  126.  
  127.     for(j=0;j<0x4000;j++)            //    Restore Original DOS-Screen
  128.         T_screen[j]=oldscreen[j];
  129.  
  130.     for(fade=0;fade<0x3f;fade++)    //    Fade In DOS-Screen
  131.     {
  132.         for(j=0;j<16;j++)
  133.         {
  134.             NewPalette[j].R=(OldPalette[j].R*fade)>>6;
  135.             NewPalette[j].G=(OldPalette[j].G*fade)>>6;
  136.             NewPalette[j].B=(OldPalette[j].B*fade)>>6;
  137.             T_SetPal(j,&NewPalette[j]);
  138.         }
  139.         V_WaitVB();                        //    Wait for Vertical Blanking
  140.     }
  141.     for(j=0;j<16;j++)
  142.         T_SetPal(j,&OldPalette[j]);//    Store Old Palette
  143.  
  144.     VB_SetCursorPos(ocurx,ocury);    //    Set Original Cursor Positions
  145.     VB_SetCursor(2);                    //    Set Cursor Normal [BIOS]
  146.  
  147.     K_EatKbHit();                        //    Eat Keypress
  148.  
  149.     return 0;
  150. }
  151.